//
//  TourViewLayout.m
//  EasyToTesco2.0
//
//  Created by knew on 2017/5/3.
//  Copyright © 2017年 EasyToTesco. All rights reserved.
//

#import "TourViewLayout.h"
#import "TourModel.h"


@implementation TourOrderLastViewLayout

- (instancetype)_initTourOrderLastViewLayout {
    self = [super init];
    [self _initLastViewLayout];
    return self;
}

- (void)_initLastViewLayout {
    self.priceRect = CGRectMake(kCellTopMargin, kCellContentMargin, WIDTH * 0.4, 49 - kCellContentMargin * 2);
    
    self.payOrderRect = CGRectMake(WIDTH - WIDTH * 0.3 - kCellTopMargin , kCellContentMargin, WIDTH * 0.3, 49 - kCellContentMargin * 2);
}

@end

#pragma mark -
@implementation TourSellOrderTableViewCellLayout

- (instancetype)_initTourSellOrderTableViewCellLayoutWithModel:(TourSellOrderModel *)tourSellerOrderModel {
    self = [super init];
    _tourSellOrderModel = tourSellerOrderModel;
    [self _initTourSellerOrderLayout];
    return self;
}

- (void)_initTourSellerOrderLayout {
    /*
     leftLabelRect;
     dataButtonRect;
     cutButtonRect;
     numberLabelRect
     addButtonRect;
     textFieldRect;
     */
    
    CGFloat height = kTourSellerOrderTableViewCellHeight - kCellContentMargin * 2;
    
    self.leftLabelRect = CGRectMake(kCellTopMargin, kCellContentMargin, kTourSellerOrderTableViewCellWidth + kCellTopMargin * 2, height);
    
    self.dataButtonRect = CGRectMake(WIDTH - height * 4 - kCellTopMargin , kCellContentMargin, height * 4, height);
    
    self.addButtonRect = CGRectMake(WIDTH - height - kCellTopMargin , kCellContentMargin, height, height);
    
    self.numberLabelRect = CGRectMake(self.addButtonRect.origin.x - WIDTH * 0.1 - kCellContentMargin , kCellContentMargin, WIDTH * 0.1, height);
    
    self.cutButtonRect = CGRectMake(self.numberLabelRect.origin.x - height - kCellContentMargin , kCellContentMargin, height, height);
    
    self.textFieldRect = CGRectMake(CGRectGetMaxX(self.leftLabelRect) + kCellTopMargin , kCellContentMargin, WIDTH * 0.6, height);
}

@end
#pragma mark -
@implementation TourSellerDetailCellHeaderLayout

- (instancetype)_initDetailCellHeaderViewLayout {
    self = [super init];
    [self _initHeaderViewLayout];
    return self;
}

- (void)_initHeaderViewLayout {
    self.leftViewRect = CGRectMake(kCellTopMargin + kCellTopMargin, kCellContentMargin, kCellTopMargin, kToueDetailTableViewHeaderHeight - 2 * kCellContentMargin);
    
    self.titleRect = CGRectMake(CGRectGetMaxX(self.leftViewRect) + kCellContentMargin, 0, WIDTH * 0.5, kToueDetailTableViewHeaderHeight);
}

@end


@implementation TourDetailTableViewCellLayout

- (instancetype)_initDetailCellLayoutWithTourProductsModel:(TourProductsModel *)tourDetailModel {
    if (!tourDetailModel) return nil;
    self = [super init];
    _tourDetailModel = tourDetailModel;
    [self _initTourDetailTableViewCellLayout];
    return self;
}

- (void)_initTourDetailTableViewCellLayout {
    /*
     leftTitleRect;
     infoRect;
     moreRect;
     garyTitleRect;
     grayLineRect;
     priceRect;
     payRect;
     */
    
    CGFloat width = WIDTH * 0.2;
    CGFloat x = WIDTH - width - kCellTopMargin;
    
    self.leftTitleRect = CGRectMake(kCellTopMargin, kCellTopMargin, WIDTH * 0.5, 30);
    self.infoRect = CGRectMake(kCellTopMargin, CGRectGetMaxY(self.leftTitleRect) + kCellContentMargin, WIDTH * 0.5, 20);
    self.moreRect = CGRectMake(kCellTopMargin, CGRectGetMaxY(self.infoRect) + kCellContentMargin, WIDTH * 0.3, 20);
    
    
    self.garyTitleRect = CGRectMake(x, kCellTopMargin, width, 15);
    
//    CGFloat margin =
    self.grayLineRect = CGRectMake(x + WIDTH * 0.05, 15/2 + kCellTopMargin, WIDTH * 0.1, 1);
    
    self.priceRect = CGRectMake(x, kCellTopMargin + kCellContentMargin + 15, width, 25);
    
    self.payRect = CGRectMake(x, kCellTopMargin + kCellContentMargin * 2 + 40, width, 30);
}

@end

@implementation TourDetailHeaderLayout

- (instancetype)_initDetailHeaderLayoutWithTourDetailModel:(TourDetailModel *)tourDetailModel {
    if (!tourDetailModel) return nil;
    self = [super init];
    _detailModel = tourDetailModel;
    [self _initDetailHeaderLayout];
    return self;
}

- (void)_initDetailHeaderLayout {
    /*
     leftImgRect
     titleRect;
     detailRect;
     phoneRect;
     addressRect
     */
    
    self.leftImgRect = CGRectMake(kCellTopMargin, kCellTopMargin * 2, kTourDetailHeaderHeight - kCellTopMargin * 4, kTourDetailHeaderHeight - kCellTopMargin * 4);
    
    self.titleRect = CGRectMake(CGRectGetMaxX(self.leftImgRect) + kCellTopMargin, kCellTopMargin, WIDTH * 0.5, kTourDetailHeaderHeight * 0.15);

    self.phoneRect = CGRectMake(CGRectGetMaxX(self.leftImgRect) + kCellContentMargin, kTourDetailHeaderHeight - kTourDetailHeaderHeight * 0.2 - kCellContentMargin , WIDTH * 0.3, kTourDetailHeaderHeight * 0.2 );
    
    self.addressRect = CGRectMake(CGRectGetMaxX(self.phoneRect) + kCellTopMargin, kTourDetailHeaderHeight - 30, WIDTH - self.leftImgRect.size.width - self.phoneRect.size.width - 3 * kCellTopMargin, kTourDetailHeaderHeight * 0.2);

    self.detailRect = CGRectMake(self.titleRect.origin.x, CGRectGetMaxY(self.titleRect), WIDTH - self.leftImgRect.size.width - kCellTopMargin * 3, kTourDetailHeaderHeight - kTourDetailHeaderHeight * 0.35 - kCellTopMargin * 2);
}

@end

@implementation TourViewLayout

- (instancetype)_initLayoutWithTourModel:(TourModel *)tourModel {
    if (!tourModel) return nil;
    self  = [super init];
    _tourModel = tourModel;
    _replaceID = tourModel.replaceID;
    [self _initCellLayout];
    return self;
}

- (void)_initCellLayout {
    
    self.leftRect = CGRectMake(kCellTopMargin, kCellTopMargin, kCellHEIGHT, kCellHEIGHT);

    self.nameRect = CGRectMake(CGRectGetMaxX(self.leftRect) + kCellTopMargin, kCellTopMargin, WIDTH - self.leftRect.size.width - kCellTopMargin * 3, 20);
    
    self.detailRect = CGRectMake(self.nameRect.origin.x, CGRectGetMaxY(self.nameRect) + kCellContentMargin, self.nameRect.size.width, kCellHEIGHT - 20 - kCellContentMargin);
    
    _height = kCellHEIGHT + kCellTopMargin * 2;
}



@end
